The events unique to each VBVoice control are described in the Toolbox Reference. Most VBVoice controls also contain common events, including:
|
Note: Earlier versions of VBVoice used synchronous events, preventing calls to out-of-process servers to be made from within these events. This limitation no longer exists.
VB
Disconnect (ByVal Channel as Integer, ByVal Reason as Integer)
C#
Void Disconnect (object sender, DisconnectEvent e)
This event procedure is called when a caller hangs up. It can occur in any control that performs voice processing. This event allows clean-up on a per-control basis. After this event occurs, a Disconnect event occurs in the LineGroup control that initiated this call. This hierarchy of events allows localized clean-up procedures or global clean-up as appropriate. The global Disconnect event in the LineGroup control occurs regardless of whether the caller hangs up first or the system hangs up first. The local Disconnect event occurs in most controls when the caller hangs up.
Note: The Disconnect event does not occur in the LineGroup control when in test mode.
Possible disconnect reasons are defined by the vbvDisconnectConstants enumeration. These constants are defined by VBVoice and can be used directly.
vbvControlHangup = 0: Call terminated at an Onhook control.
vbvSysErrorHangup = 1: Call terminated due to a system error in a control.
vbvCallerHangup = 2: Call terminated due to the caller hang-up indication from the telephone switch.
vbvInvalidHangup = 3: Call terminated due to default invalid digits or no digits timeout handling.
vbvSysStopping = 4: System stops because of the StopSystem(False) method in the VBVFrame control.
vbvSysStopped = 5: System is stopped because of the StopSystem(True) method in the VBVFrame control.
vbvSubReturn = 7
vbvGlobalTone = 8
vbvHelpDigit = 9
VB
Enter (ByVal Channel as Integer, Greeting as Object) ' Voice processing controls
Enter(ByVal
Channel as Integer) ' Other controls
C#
Void EnterEvent (object sender, EnterEvent e)
This event occurs when a call enters a control and it depends on the input by which the call arrives. The EnterB event occurs in controls that have two input nodes and the call enters through the second (lower) input.
The Enter events give VB code an opportunity to change some of the control characteristics by setting its runtime properties on a call-by-call basis or by bypassing the control altogether using the GotoNode property or TakeCall method.
The footprint of the Enter event in voice processing controls that have an Entry greeting is different from other controls: They have an additional parameter called Greeting as Object. This parameter is the greeting object that is played on control entry. The Enter event can change this greeting as required.
Changing this greeting only affects the greeting for that call at that instant. Subsequent calls, or re-entry into the control by the same call, use the greeting as defined at design time (unless this is also changed).
NOTE: In the .NET environment, the VBVoice Enter event is renamed as EnterEvent. This change was required because Enter is a standard event for .NET components
VB
Exit (ByVal Channel As Integer, Node As Integer)
C#
Void Exit (object sender, ExitEvent e)
This event occurs when a call leaves a control, but before the Enter/EnterEvent event occurs in the destination control. The node parameter is the node number that indicates the destination control. However, if the exit event is due to a no digits error, invalid digit error, caller hangup, or help digit detected, then the node value will be a vbvExitNodeConstants (see below). Nodes are numbered from 0.
The exit node can be changed in the event procedure to override the default behavior. If a caller hangup is detected, the Exit event occurs first, followed by the Disconnect event sequence.
If an error occurs while the call is being handled in the control, the VoiceError event occurs instead.
vbvExitNodeConstants |
vbvNoDigitsExit = -1 |
|
vbvInvalidDigitsExit = -2 |
|
vbvCallerHangupExit = -3 |
|
vbvHelpDigitExit = -4 |
VB
PlayRequest (ByVal Channel as Integer, ByVal PhraseName as String,
Phrase as Object)
C#
void PlayRequest (object sender, PlayRequestEvent e)
This event occurs when a greeting contains a VB Phrase. Every VB Phrase is named so that it can easily be identified in a situation where a control has multiple VB Phrases.
In the PlayRequest event procedure, your VB code should modify the phrase object passed in as a parameter using the Phrase methods and properties. This event is used to create custom greetings which are not fixed at design time, but must be determined at run time.
There are other ways of dynamically configuring greetings. For example, you can select a VAP phrase by index or name, which is generated from a VB variable (through a VBVFrame Transfer property) or from another VBVoice control such as a GetDigits or DataFind.
VB
PhraseError (ByVal Channel as Integer, Phrase as Object, ByVal
ErrType as Integer)
C#
Void PhraseError (object sender, PhraseErrorEvent e)
Phrase errors can occur when :
VBVoice cannot open a specified file
VBVoice cannot find a specified phrase within a file
An invalid parameter was specified in a System Phrase
Most of these errors are found during design checking or at startup, but some errors can occur at runtime for System phrases that contain calculated values or if files are erased after startup.
ErrType is one of the predefined vbvPhraseErrorConstants:
vbvFileOpenError = 0
vbvPhraseNotFound = 1
vbvControlNotFound = 2
vbvBadTimeSpec = 3
vbvBadNumber = 4
vbvBadDate = 5
vbvPhraseNameNotFound = 6
If a PhraseError event occurs, your event code can do one of the following:
Allow the default action to occur (which terminates the call). This behavior can be overridden using the INI file setting IgnorePhraseErrors.
Replace the phrase in error with a new phrase using Phrase methods and properties. To avoid infinite loops, if an error occurs while processing the replacement phrase, an event is not generated.
VB
VoiceError (Channel as Integer, ErrorType as Integer, ErrorData as
Integer, Processed as Integer)
C#
Void VoiceError (object sender, VoiceErrorEvent e)
This event occurs when a non-fatal error happens in the control. A non-fatal error happens when an unexpected situation has occurred and the control does not know how to deal with it. This does not necessarily mean there is a hardware malfunction. Generally the call is terminated if the error is not processed. This event allows VB code to intercept the error and decide whether to allow the call to continue.
When an error event occurs, the control generating the event is generally not able to continue normal processing.
Your code can choose to ignore the error by:
Setting the parameter Processed = True, or
Redirecting the call to a new control using the GotoNode or the TakeCall method.
If none of these actions are taken, the call is terminated. If you choose to ignore the error and do not set the next control to be processed (using either GotoNode, TakeCall), the call will re-enter the control that fired the VoiceError event.
ErrType can be one of the following constants:
unexpected_driver_event = 15
dberror=22
notauthorized=23
dctlerror = 194
EXAMPLES
VB.NET:
Private Sub PlayGreeting1_VoiceError(ByVal channel As Integer, ByVal ErrorType As Integer, ByVal ErrorData As Long, Processed As Integer)
Static cnt As Integer
cnt = cnt + 1
If ((cnt Mod 4) > 0)
Then `try 3 times
Processed = True `ignore
error, reenter control
Else
PlayGreeting1.GotoNode(channel)
= 0 `exit
End If
End Sub
C#:
int cnt;
private void playGreeting1_VoiceError(object sender,
_DPlayGreetingEvents_VoiceErrorEvent e)
{
cnt++;
int res;
Math.DivRem(cnt,4,out res);
if (res
> 0)
e.processed = 1;//try three times
else
playGreeting1.GotoNode[e.channel] =
0;//exit
}